package cn.stacey.springmvc.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ParameterController {
	//http://localhost/springmvc/param/parameter1.action?title=java
	@RequestMapping("/param/parameter1")
	public String parameter(String title) {  //传过来的参数必须与此方法中的形参字段对应
		System.out.println(title);
		return "success";
		
	}
	
	//http://localhost/springmvc/param/parameter2.action?title=java&s=中
	@RequestMapping("/param/parameter2")
	public String parameter2(String title,String s) {  //传过来的参数必须与此方法中的形参字段对应
		System.out.println(title);
		//传过来的中文会乱码
		System.out.println(s);
		return "success";
		
	}
	
	//http://localhost/springmvc/param/parameter3.action?title=java
		@RequestMapping("/param/parameter3")
		public String parameter2(@RequestParam("title") String title1) {  
			//传过来的参数必须与此方法中的形参字段对应,如果想要参数不一样可以用注解
			//@RequestParam("title")注解里面的字段与url中的字段相同即可
			System.out.println(title1);
			return "success";			
		}
		
		
}
